#!/bin/bash

# LIMPIEZA CONFIGURACION PREVIA
./limpiezaInterfaces.sh

# ACTIVACION DE LA FUNCION DE ROUTER DEL SO
echo "1" >> /proc/sys/net/ipv4/ip_forward

# MASCARAS DE RED
Netmask24="255.255.255.0"
Netmask25="255.255.255.128"
Netmask26="255.255.255.192"
Netmask27="255.255.255.224"
Netmask28="255.255.255.240"
Netmask29="255.255.255.248"
Netmask30="255.255.255.252"

# INTERFACES
interfaz1=`ifconfig | egrep "eth" | sed 's/^\([A-Za-z0-9:]*\).*/\1/'`
interfaz2=$interfaz1":0"

# IPS
IP1="10.61.7.182"
IP2="10.111.25.129"

# DIRECCIONES DE BROADCAST
BR1="10.61.7.183"
BR2="10.111.25.255"

# DIRECCIONES DE RED
gianolla="192.168.25.0"
pauls="10.61.7.176"
aleandro="10.61.7.144"
gonzales="10.111.25.0"
chavez="10.111.25.128"
gimenez="10.61.7.180"
suar="10.61.6.128"
bertucelli="10.61.5.0"

# DIRECCIONES DE GATEWAY
porGimenez="10.61.7.181" 
porChavezH13="10.111.25.131" 

# CONFIGURACION DE LAS INTERFACES DEL ROUTER
ifconfig $interfaz1 $IP1 broadcast $BR1 netmask $Netmask30
ifconfig $interfaz2 $IP2 broadcast $BR2 netmask $Netmask25

# CONFIGURACION DE LA TABLA DE RUTEO
route add -net $gianolla netmask $Netmask24 dev $interfaz1 metric 1 gw $porGimenez  
route add -net $pauls netmask $Netmask30 dev $interfaz2 metric 2 gw $porChavezH13
route add -net $aleandro netmask $Netmask28 dev $interfaz2 metric 1 gw $porChavezH13
route add -net $gonzales netmask $Netmask25 dev $interfaz2 metric 1 gw $porChavezH13
route add -net $suar netmask $Netmask27 dev $interfaz2 metric 3 gw $porChavezH13
route add -net $bertucelli netmask $Netmask24 dev $interfaz2 metric 4 gw $porChavezH13  

#CONFIGURACION DNS
./DNStigre.sh
